<!-- this function displays a text field which the user can use to 
      input his opinion on the web site's current configuration/layout or
       his opinion of the company. This will not be displayed on the website,
        but is merely a tool for the benefit of the company and developers -->  


<?php 

     //this section displays the steps the user should take to fill out the form, the 
     //text field that will take user input, and two buttons one to submit and one to reset.  
     echo '
       <div id="BodyMain">

	  <h2 class="header1">Feedback</h2><br />

          <p class="bodycopy center">
            Your business is very important to us, and as such if you have any concerns or positive
            feedback please leave it in the textbox below. <br/> Please limit yourself to 500 characters.
            Of course if the allocated space is not enough feel free to 
            <a href = "?page=contact" class = "SiteLink">Contact us</a>:
          </p>

            
         <!-- COMMENT: This is the textfield that will take in user input. -->
         <form action = "?page=feedback" method="post">
            <p class = "bodycopy center">
               <textarea name = "feedback" rows = "10" cols = "75">(Maximum of 500 characters)</textarea>
               <br />
               <input type = "submit" value = "Submit" />
               <input type = "reset" value = "Reset" />
            </p>
         </form>

       </div>';
    
   if (isset($_POST['feedback'])) { 
      $message = trim($_POST["feedback"]);
      if ($message ==  "" || $message == "(Maximum of 500 characters)"){
         echo '<p class = "feedbackCorrect">You need to enter a message before you submit!</p>';}
      else {
         $writer = "anonymous";
         if(isset($_SESSION['Username'])) { $writer = $_SESSION['Username']; }
         $feedbackfile=fopen("feedback.txt","a");
         fwrite($feedbackfile, $writer." wrote:\n".$message."\n\n");
         fclose($feedbackfile);
         echo '<p class = "feedbackCorrect">Thank you for your feedback!</p>';
      }
   }
   
   
?> 

